package com.sskj.login.presenter;


import com.alibaba.android.arouter.launcher.ARouter;
import com.sskj.common.base.HttpData;
import com.sskj.lib.bean.enums.CodeTypeEnum;
import com.sskj.lib.http.CallBackOption;
import com.sskj.lib.router.provider.SendSmsProvider;
import com.sskj.login.http.HttpConfig;
import com.sskj.login.ui.activity.RegisterActivity;

/**
 * @author Hey
 * Create at  2019/08/21 11:29:56
 */
public class RegisterActivityPresenter extends BasePresenter<RegisterActivity> {
    public void sendCode(String slideCode, String account, String areaCode) {
        SendSmsProvider smsProvider = ARouter.getInstance().navigation(SendSmsProvider.class);
        smsProvider.send(mView, account, areaCode, CodeTypeEnum.STATUS_1, slideCode, new SendSmsProvider.OnSend() {
            @Override
            public void onSuccess() {
                mView.sendCheckCodeSuccess();
            }

        });
    }

    public void register(String account, String pswd, String invitationCode, String code, String areaCode) {
        httpService.register(account, pswd, invitationCode, code, areaCode)
                .execute(new CallBackOption<HttpData>() {
                }.loadBind(mView)
                        .execute(httpData -> {
                            if (httpData.getStatus() == HttpConfig.OK) {
                                mView.registerSuccess();
                            }
                        }));
    }

}
